import json
import unittest
import app
from parameterized import parameterized
from aip.login_demo import loginDemoAPI
from utils import common_assert


def build_data():
    json_data = []
    file = app.BASE_DIR + "/data/login.json"

    with open(file, encoding="utf8") as f:
        json_load = json.load(f)
        for test_data in json_load:
            login_data = test_data.get("login_data")
            status_code = test_data.get("status_code")
            success = test_data.get("success")
            code = test_data.get("code")
            message = test_data.get("message")
            json_data.append((login_data,status_code,success,code,message))
    print(json_data)
    return json_data


class Test01LoginDemoParam(unittest.TestCase):
    def setUp(self) -> None:
        self.login_d_api = loginDemoAPI()

    # 登录
    @parameterized.expand(build_data())
    def test01_login_d(self,login_data, status_code, success, code, message):
        response = self.login_d_api.login_d(login_data)
        print(response.json())
        common_assert(self, response, status_code, success, code, message)












